package com.telra.app.server.config;

import com.telra.app.server.cassandra.CassandraService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

/**
 * User: jamesarlet
 * Date: 1/5/12
 * Time: 8:58 PM
 */

@Configuration
@ImportResource("classpath:/spring.xml")

public class ConfigMgr {

    private @Value("#{cassandraProperties.clustername}") String clustername;
    private @Value("#{cassandraProperties.host}") String host;
    private @Value("#{cassandraProperties.port}") String port;
    private @Value("#{cassandraProperties.keyspace}") String orderKeyspace;


    public @Bean (name="cassandraService") CassandraService cassandraService() {
        CassandraService cassandraService =  new CassandraService();
        cassandraService.setClusterName(clustername);
        cassandraService.setHost(host);
        cassandraService.setPort(port);
        cassandraService.setKeyspaceName(orderKeyspace);

        return cassandraService;
    }

}